package ControlLayer;
import ModelLayer.*;
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported

/**
 * Controller class for the address book
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class AddressCtr
{
    
    private AddressList addressList;
    
    
    public AddressCtr(/*---*/)
    {
        addressList = AddressList.getInstance();
        
    }
    
    public Person findPerson(String name)
    {
         return addressList.findPerson(name);
    }
    
    public Person findPersonId(long id)
    {
        return addressList.findPersonId(id);
    }
    
    
    public void createPerson(String name, String address, String city, String zip_code, String phone, long id)
    {   
       addressList.personList.add(new Person(name, address, city, zip_code, phone, id));
    }
    
    public ArrayList<Person> listPersonsNr()
    {
        return addressList.listPersons();
    }
    
    public void deletePerson(long id)
    {
        Person person = findPersonId(id);
        if(person !=null)
        addressList.deletePerson(id);
        
    }
    
    public void updatePerson(String name, String address, String city, String zip_code, String phone, long id)
    {
        addressList.updatePerson(name, address, city, zip_code, phone, id);
    }
    
   
}
